using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Nizm0.QOT.Library.Options
{
    public partial class ucSQLOptions : UserControl, Library.Objects.IOption
    {
        //private Properties.Settings set = Properties.Settings.Default;

        public ucSQLOptions()
        {
            InitializeComponent();
            Fill();
        }

        public void Fill()
        {
            textBox_CommandTimeout.Text = Settings.Instance.CommandTimeout.ToString();// Properties.Settings.Default.CommandTimeout.ToString();
            textBox_ConectionTimeout.Text = Settings.Instance.ConectionTimeout.ToString();
        }



        public void SaveSettings()
        {
            //set.CommandTimeout = Convert.ToInt32(textBox_CommandTimeout.Text);
            Settings.Instance.CommandTimeout = int.Parse(textBox_CommandTimeout.Text);
            Settings.Instance.ConectionTimeout = int.Parse(textBox_ConectionTimeout.Text);
            Settings.Instance.Save();
            //set.Save();
        }

        #region IOption
        private string _optionPath = "SQL\\MSSql";
        public string OptionPath
        {
            get
            {
                return _optionPath;
            }
            set
            {
                _optionPath = value;
            }
        }

        private string _optionName = "MSSql";
        public string OptionName
        {
            get { return _optionName; }
        }

        private bool _optionChange = true;
        public bool OptionChanged
        {
            get { return _optionChange; }
        }

        public bool Save()
        {
            SaveSettings();
            return true;
        }

        public Library.Objects.IOption Show()
        {
            return new ucSQLOptions();
        }
        #endregion
    }
}
